//
//  MenuCell.m
//  PriceOnline
//
//  Created by Le Anh Tai on 8/14/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import "MenuCell.h"
#import "UIConstants.h"

@implementation MenuCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self)
    {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.font = FONT_HELVETICANEUE(15);
        _titleLabel.textColor = _textColor;
        [_subView addSubview:_titleLabel];
        
        _valueLabel = [[UILabel alloc] init];
        _valueLabel.backgroundColor = [UIColor clearColor];
        _valueLabel.font = FONT_HELVETICANEUE(15);
        _valueLabel.textAlignment = NSTextAlignmentRight;
        _valueLabel.textColor = _textColor;
        [_subView addSubview:_valueLabel];
    }
    
    return self;
}

- (void)reloadTheme
{
    [super reloadTheme];
    
    _titleLabel.textColor = _textColor;
    _valueLabel.textColor = _textColor;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    NSInteger paddingLeft = 12;
    NSInteger paddingRight = 12;
    _titleLabel.frame = RECT(paddingLeft, 0, _subView.width, self.height);
    
    [_valueLabel sizeToFit];
    
    self.titleLabel.width = _subView.width - (_valueLabel.width + paddingLeft + paddingRight);
    
    _valueLabel.frame = RECT(self.titleLabel.right, self.titleLabel.top, self.width - self.titleLabel.right - paddingRight, _subView.height);
}

@end
